#include <iostream>
using namespace std;

class Fruit
{
public:
    virtual void sayName() = 0;

};

class FruitFactory
{
public:
    virtual Fruit* getApple() = 0;
    virtual Fruit* getBanana() = 0;

};

class SouthBanana : public Fruit
{
public:
    virtual void sayName()
    {
        cout << "south banana\n" << endl;

    }
};

class SouthApple : public Fruit
{
public:
    virtual void sayName()
    {
        cout << "south apple\n" << endl;

    }
};

class NorthBanana : public Fruit
{
public:
    virtual void sayName()
    {
        cout << "north banana\n" << endl;

    }
};

class NorthApple : public Fruit
{
public:
    virtual void sayName()
    {
        cout << "north apple\n" << endl;

    }

  
};
class NorthFruitFactory : public FruitFactory
{
public:
    virtual Fruit* getApple()
    {
        return new NorthApple();
    }
    virtual Fruit* getBanana()
    {
        return new NorthBanana();
    }
};
class SouthFruitFactory : public FruitFactory
{
public:
    virtual Fruit* getApple()
    {
        return new SouthApple();
    }
    virtual Fruit* getBanana()
    {
        return new SouthBanana();
    }
};
int main3()
{
    FruitFactory* factory = NULL;
    Fruit* fruit = NULL;
    factory = new SouthFruitFactory();
    fruit = factory->getApple();
    fruit->sayName();

    delete fruit;
    fruit = factory->getBanana();
    fruit->sayName();
    delete fruit;

    factory = new NorthFruitFactory();
    fruit = factory->getApple();
    fruit->sayName();

    delete fruit;
    fruit = factory->getBanana();
    fruit->sayName();
    delete fruit;




    system("pause");
    return 0;
}